list Derived Type

type, public :: list

Defines a generic, dynamically sizable list.


Type-Bound Procedures

procedure, public :: clear => list_clear

  • private subroutine list_clear(this)

    Clears the entire list.

    Arguments

    Type IntentOptional Attributes Name
    class(list), intent(inout) :: this

    The list object.

procedure, public :: count => list_get_count

  • private pure function list_get_count(this) result(rst)

    Gets the number of items stored in the list.

    Arguments

    Type IntentOptional Attributes Name
    class(list), intent(in) :: this

    The list object.

    Return Value integer(kind=int32)

    The number of items stored in the list.

procedure, public :: get => list_get

  • private function list_get(this, i) result(rst)

    Gets the requested item from the list.

    Arguments

    Type IntentOptional Attributes Name
    class(list), intent(in) :: this

    The list object.

    integer(kind=int32), intent(in) :: i

    The one-based index of the item to retrieve.

    Return Value class(*), pointer

    A pointer to the requested object.

procedure, public :: get_capacity => list_get_capacity

  • private pure function list_get_capacity(this) result(rst)

    Gets the capacity of the list.

    The capacity is the available "space" in the collection for adding additional items without resizing the internal data store. This capacity includes the currently utilized space. To obtain a count of the actual number of items stored in the list use the count routine.

    Arguments

    Type IntentOptional Attributes Name
    class(list), intent(in) :: this

    The list object.

    Return Value integer(kind=int32)

    The capacity of the list.

procedure, public :: insert => list_insert

  • private subroutine list_insert(this, i, x, manage)

    Inserts an item into the list.

    Arguments

    Type IntentOptional Attributes Name
    class(list), intent(inout) :: this

    The list object.

    integer(kind=int32) :: i

    The one-based index defining where to put the item.

    class(*), intent(in) :: x

    The object to store.

    logical, intent(in), optional :: manage

    An optional input used to determine if the list should manage memory for this object. If set to true a clone of x is stored and the list will handle management of resources held by the clone. If false, the list will not manage resources held by x and x itself will be stored. Notice, in this manner it is possible for x to go out of scope while the list still persists thereby resulting in a potentially undefined behavior. It is recommended to use the default value of true except for very specific and well controlled edge cases.

procedure, public :: pop => list_pop

  • private subroutine list_pop(this)

    Pops the last item off the back of the list.

    Arguments

    Type IntentOptional Attributes Name
    class(list), intent(inout) :: this

    The list object.

procedure, public :: push => list_push

  • private subroutine list_push(this, x, manage)

    Pushes an item onto the back of the list.

    Arguments

    Type IntentOptional Attributes Name
    class(list), intent(inout) :: this

    The list object.

    class(*), intent(in), target :: x

    The object to store.

    logical, intent(in), optional :: manage

    An optional input used to determine if the list should manage memory for this object. If set to true a clone of x is stored and the list will handle management of resources held by the clone. If false, the list will not manage resources held by x and x itself will be stored. Notice, in this manner it is possible for x to go out of scope while the list still persists thereby resulting in a potentially undefined behavior. It is recommended to use the default value of true except for very specific and well controlled edge cases.

procedure, public :: remove => list_remove

  • private subroutine list_remove(this, i)

    Removes an item from the list.

    Arguments

    Type IntentOptional Attributes Name
    class(list), intent(inout) :: this

    The list object.

    integer(kind=int32) :: i

    The one-based index defining which item to remove.

procedure, public :: set => list_set

  • private subroutine list_set(this, i, x, manage)

    Sets the specified item into the list.

    Arguments

    Type IntentOptional Attributes Name
    class(list), intent(inout) :: this

    The list object.

    integer(kind=int32), intent(in) :: i

    The one-based index defining where to put the item.

    class(*), intent(in), target :: x

    The object to store.

    logical, intent(in), optional :: manage

    An optional input used to determine if the list should manage memory for this object. If set to true a clone of x is stored and the list will handle management of resources held by the clone. If false, the list will not manage resources held by x and x itself will be stored. Notice, in this manner it is possible for x to go out of scope while the list still persists thereby resulting in a potentially undefined behavior. It is recommended to use the default value of true except for very specific and well controlled edge cases.

procedure, public :: set_capacity => list_set_capacity

  • private subroutine list_set_capacity(this, n)

    Sets the capacity of the list.

    The capacity is the available "space" in the collection for adding additional items without resizing the internal data store. This capacity includes the currently utilized space. To obtain a count of the actual number of items stored in the list use the count routine.

    Arguments

    Type IntentOptional Attributes Name
    class(list), intent(inout) :: this

    The list object.

    integer(kind=int32), intent(in) :: n

    The new capacity of the list. This value must be greater than or equal to 1.